<%@ page language="java" contentType="text/html;charset=UTF-8" pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html>
<head>
<%
	String bathPath = request.getContextPath();
	pageContext.setAttribute("bathPath", bathPath);
%>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>门禁管理系统</title>
<script type="text/javascript" src="${bathPath}/js/jquery-1.9.1.min.js" ></script>>
<link type="text/css" rel="stylesheet" href="${bathPath}/css/index3.css?v=g" />
<link type="text/css" rel="stylesheet" href="${bathPath}/css/suoding.css" />
<script type="text/javascript" src="${bathPath}/js/ajaxSessionOut.js" ></script>

<!-- layer -->
<link type="text/css" rel="stylesheet" href="${bathPath}/js/layer/skin/layer.css"/>
<script type="text/javascript" src="${bathPath}/js/layer/layer.js" ></script>

<!-- validation -->
<script type="text/javascript" src="${bathPath}/js/jquery-validation/jquery.validate.js"></script>

<!-- 改变提示框按钮的颜色 -->
<style type="text/css">
	.my-skin .layui-layer-btn a {
	background-color:#009688;
}
</style>
</head>
<body style="background-image:url(${bathPath}/image/background.png)">
 <div class="pass" style="right:0px;">
	    <div class="pass-kuang" align="center">
	    	<a href="http://www.adkfp.com/" target="_Blank" title="费浦官网" > 
	        	<img src="${bathPath}/image/house.png" style="width:17px; height:17px;" />
	       	</a>
	    </div>
	    <div class="pass-kuang" align="center" title="锁定系统">
	        <img src="${bathPath}/image/lock.png" style="width:15px; height:16px;" id="suoDing"/>
	    </div>
	    <div class="pass-kuang" align="center" title="密码修改" >
	      	<img src="${bathPath}/image/password.png" style="width:16px; height:16px;" id="repassword" />
	    </div>
	    <div class="pass-kuang" align="center" title="退出系统" >
	      	<img src="${bathPath}/image/exit.png" style="width:15px; height:15px;" id="loginOut"/>
	    </div>
</div>
	<div id="zong">
	<!-- <div class="top"> -->
    	<div class="top-logo" style="left:-20px;">
        	<img src="${bathPath}/image/logo2.png" style="width:173px; height:55px;"/>
        </div>
        <div class="top-daohang" style="top:100px;left:1100px;">
        	<a href="#" class="active" >
        		<div class="top-daohang-button" align="center" id="xi">
        			<span>系统管理</span>
        		 	<img src="${bathPath}/image/button-8.png" style="width:47px; height:47px;"/>
                </div>
            </a>
            <a href="#">
        		<div class="top-daohang-button" align="center" id="ji">
                    <span>基础资料</span>
                    <img src="${bathPath}/image/button-1.png" style="width:47px; height:47px;" />
            	</div>
            </a>
            <a href="#">
           		<div class="top-daohang-button" align="center" id="she">
               	 	<span>设备参数</span>
               	 	<img src="${bathPath}/image/button-2.png" style="width:47px; height:47px;" />
                </div>
            </a>
            <a href="#" class="active">
                <div class="top-daohang-button" align="center" id="tong">
                    <span>通行管理</span>
                    <img src="${bathPath}/image/button-3.png" style="width:47px; height:47px;" />
                </div>
            </a>
            <a href="#" class="active">
                <div class="top-daohang-button" align="center" id="jian">
                    <span>监控管理</span>
                    <img src="${bathPath}/image/button-4.png" style="width:47px; height:47px;" />
                </div>
            </a>
            <a href="#" class="active">
                <div class="top-daohang-button" align="center" id="kao">
                    <span>考勤管理</span>
                    <img src="${bathPath}/image/button-5.png" style="width:47px; height:47px;" />
                </div>
            </a>
            <a href="#" class="active">
                <div class="top-daohang-button" align="center" id="xun">
                    <span>巡更管理</span>
                    <img src="${bathPath}/image/button-6.png" style="width:47px; height:47px;" />
                </div>
            </a>
            <a href="#" class="active">
                <div class="top-daohang-button" align="center" id="fang">
                    <span>访客管理</span>
                    <img src="${bathPath}/image/button-7.png" style="width:47px; height:47px;" />
                </div>
            </a>
        </div>
<!--     </div> -->
    
    
    
    <div class="zhu">
        <div class="zhu-left" >
        <div id="xitong">
        	<div class="zhu-fen-zi"><span>系统管理</span></div> 
        	<div class="zhu-fen" onclick="manageuser()"  id="xitong1"><a href="#">操作员管理</a></div>
            <div class="zhu-fen" onclick="managerole()"  id="xitong2"><a href="#">角色管理</a></div>
            <div class="zhu-fen" onclick="managepage()"  id="xitong3"><a href="#">页面管理</a></div>
        </div>
        </div>
        <div class="zhu-left">
        <div id="jichu">
       		<div class="zhu-fen-zi"><span>基础资料</span></div>
        	<!-- <div class="zhu-fen"  id="bianse"  onclick="aDKNetGroup()"><a href="javascript:void(0)">组织机构设置</a></div> -->
        	<div class="zhu-fen" id="jiC1" onclick="aDKNetGroup()"><a href="#">组织机构设置</a></div>
            <div class="zhu-fen" id="jiC2" onclick="aDKDept()"><a href="#">部门设置</a></div>
            <div class="zhu-fen" id="jiC3" onclick="aDKUserInfo()"><a href="#">人员资料</a></div>
            <div class="zhu-fen" id="jiC4" onclick="aDKCardInfo()"><a href="#">卡片管理</a></div>
            <!-- <div class="zhu-fen"><a href="#">操作人员管理</a></div> -->
            </div>
        </div>
        <div class="zhu-left">
        <div id="canshu">
        	<div class="zhu-fen-zi"><span>设备参数</span></div>
        	<div class="zhu-fen" id="sheB1" onclick="aDKController()"><a href="#">控制器管理</a></div>
            <div class="zhu-fen" id="sheB2" onclick="aDKDoor()"><a href="#">门参数管理</a></div>
            </div>
        </div>
        <div class="zhu-left">
        <div id="tongxing">
        	<div class="zhu-fen-zi"><span>通行管理</span></div>
        	<div class="zhu-fen" id="tongX1" onclick="aDKPowerGroup()"><a href="#">权限组设置</a></div>
            <div class="zhu-fen" id="tongX2"><a href="#">门点权限管理</a></div>
            <div class="zhu-fen" onclick="aDKUserGroup()" id="tongX3"><a href="#">人员权限管理</a></div>
            </div>
        </div>
        <div class="zhu-left">
        <div id="jiankong">
        	<div class="zhu-fen-zi"><span>监控管理</span></div>
        	<div class="zhu-fen" id="jianK1" onclick="aDKAccessLog()"><a href="#">门状态查询</a></div>
            <div class="zhu-fen" id="jianK2" onclick="aDKAccessLog1()"><a href="#">刷卡记录查询</a></div>
            </div>
        </div>
        <div class="zhu-left">
        <div id="guan">
        	<div class="zhu-fen-zi"><span>考勤管理</span></div>
        	</div>
        </div>
        <div class="zhu-left">
        <div id="li">
        	<div class="zhu-fen-zi"><span>巡更管理</span></div>
        	</div>
        </div>
        <div class="zhu-left">
        <div id="ke">
        	<div class="zhu-fen-zi"><span>访客管理</span></div>
        	</div>
        </div>
    </div>
    
    <!-- 修改密码 -->
<div id="editPassword_dialog" style="display:none;">
	<form id="editPassword_form" style="margin:5px;">
		<table style="">
			<tr valign="middle">
				<td align="right">旧密码：</td>
				<td>
					<input type="password" id="old_pass" name="old_pass" class="input_0" />
				</td>
				<td align="left" valign="middle" >
					<span style="color:red;"></span>
				</td>
			</tr>
			<tr valign="middle">
				<td align="right">新密码：</td>
				<td>
					<input type="password" id="new_pass" name="new_pass" class="input_0" />
				</td>
				<td align="left" valign="middle" >
					<span style="color:red;"></span>
				</td>
			</tr>
			<tr valign="middle">
				<td align="right">确认新密码：</td>
				<td>
					<input type="password" id="re_new_pass" name="re_new_pass" class="input_0" />
				</td>
				<td align="left" valign="middle" >
					<span style="color:red;"></span>
				</td>
			</tr>	
		</table>
	</form>
	<div align="center" style="margin:10px 10px 5px 0px;">
		<button id="saveBtu" class="btu_0" >保存</button>
		<button id="closeBtu" class="btu_0" >取消</button>
	</div>
</div>
    
<script type="text/javascript">
	
 $(function(){
	quanxian();
	
	//setTimeout("aDKNetGroup()",1000);
	//setInterval("aDKNetGroup()",1000);
});   

function quanxian(){
	if(${u}==4){
		$("#xitong1").hide();
		$("#ji").hide();
		$("#jichu").hide();
	}
}
	
	//点击一级目录跳转二级目录
	$(function () {
        $('.top-daohang a').click(function () {
            $(this).addClass('active').siblings().removeClass('active');
            $(".zhu .zhu-left").eq($(this).index()).show().siblings().hide();
        })
    }) 
    //点击改变左侧菜单div颜色
    $('.zhu-left').on('click','.zhu-fen',function(){
            $(this).addClass("bianse").siblings().removeClass("bianse");
        });

	var topIframeHeight = 0;//调整iframe尺寸
	
	function iframeResize(){
		var hei = $("body").height()-61;
		$("#myIframe").height(hei);
		topIframeHeight = hei-3;
	}
	//操作员管理
	function manageuser(){
		$("#myIframe").attr("src","${bathPath}/aDKManageUser/index.action");
	}
	//角色管理
	function managerole(){
		$("#myIframe").attr("src","${bathPath}/aDKManageRole/index.action");
	}
	//页面管理
	function managepage(){
		$("#myIframe").attr("src","${bathPath}/aDKManagePage/pageList.action");
	}
	//组织机构页面
	function aDKNetGroup(){
		$("#myIframe").attr("src","${bathPath}/aDKNetGroup/tree.action");
	}
	/* function aDKNetGroup(){
		$("#myIframe").empty().load("${bathPath}/aDKNetGroup/tree.action",function(){
			$(this).loaded;
		});
	} */ 
	//部门信息页面
	function aDKDept(){
		$("#myIframe").attr("src","${bathPath}/aDKDept/index.action");
	}
	//人员资料
	function aDKUserInfo(){
		$("#myIframe").attr("src","${bathPath}/aDKUserInfo/index.action");
	}
	//卡片管理
	function aDKCardInfo(){
		$("#myIframe").attr("src","${bathPath}/aDKCardInfo/index.action");
	}
	//控制器管理
	function aDKController(){
		$("#myIframe").attr("src","${bathPath}/aDKController/index.action");
	}
	//门参数管理
	function aDKDoor(){
		$("#myIframe").attr("src","${bathPath}/aDKDoor/index.action");
	}
	//权限组设置
	function aDKPowerGroup(){
		$("#myIframe").attr("src","${bathPath}/aDKPowerGroup/index.action");
	}
	//权限组设置
	function aDKUserGroup(){
		$("#myIframe").attr("src","${bathPath}/aDKUserGroup/index.action");
	}
	//门状态查询
	function aDKAccessLog(){
		$("#myIframe").attr("src","${bathPath}/aDKAccessLog/index.action");
	}
	//刷卡记录查询
	function aDKAccessLog1(){
		$("#myIframe").attr("src","${bathPath}/aDKAccessLog/index1.action");
	}
	$(function(){
		iframeResize()
	});
	
	//退出
	$("#loginOut").click(function(){
		
		layer.confirm('确认退出吗？', {icon: 3, title:'提示'}, function(index){

		    window.location.href = "${bathPath}/login/loginout.action";
		    layer.close(index);
		});
	});
	
	//锁定
	$("#suoDing").click(function(){
		layer.confirm('确认锁定界面？', {icon:3, title:'提示'}, function(index){
			document.getElementById('suo').style.display = "block"
		    /* window.location.href = "${bathPath}/login/loginout.action"; */
		    layer.close(index);
		});
	});
	
	//空页面
	$("#xi").click(function(){document.getElementById('kong').style.display = "block";});
	$("#ji").click(function(){document.getElementById('kong').style.display = "block";});
	$("#she").click(function(){document.getElementById('kong').style.display = "block";});
	$("#tong").click(function(){document.getElementById('kong').style.display = "block";});
	$("#jian").click(function(){document.getElementById('kong').style.display = "block";});
	$("#kao").click(function(){document.getElementById('kong').style.display = "block";});
	$("#xun").click(function(){document.getElementById('kong').style.display = "block";});
	$("#fang").click(function(){document.getElementById('kong').style.display = "block";});
	$("#xitong1").click(function(){document.getElementById('kong').style.display = "none";});
	$("#xitong2").click(function(){document.getElementById('kong').style.display = "none";});
	$("#xitong3").click(function(){document.getElementById('kong').style.display = "none";});
	$("#jiC1").click(function(){document.getElementById('kong').style.display = "none";});
	$("#jiC2").click(function(){document.getElementById('kong').style.display = "none";});
	$("#jiC3").click(function(){document.getElementById('kong').style.display = "none";});
	$("#sheB1").click(function(){document.getElementById('kong').style.display = "none";});
	$("#sheB2").click(function(){document.getElementById('kong').style.display = "none";});
	$("#tongX1").click(function(){document.getElementById('kong').style.display = "none";});
	$("#tongX2").click(function(){document.getElementById('kong').style.display = "none";});
	$("#tongX3").click(function(){document.getElementById('kong').style.display = "none";});
	$("#jianK1").click(function(){document.getElementById('kong').style.display = "none";});
	$("#jianK2").click(function(){document.getElementById('kong').style.display = "none";});
	
	$(function(){
		//验证新旧密码一样
		$.validator.addMethod(
		    "rePassword",
		    function (value, element, param){
		    	return (value == $("#new_pass").val()); 
		    },
		    "与新密码不一样"
	    );
		
		$("#editPassword_form").validate({
			//debug:true,
		    /**//* 设置验证规则 */    
		    rules: {     
		    	old_pass: {     
		            required:true,
		            remote:{  
		                 url:"<%=request.getContextPath()%>/aDKManageUser/checkUserPassword.action",  
		                 type:"post",  
		                 dataType:"json",  
		                 data:{password:function(){
		                	 return $.trim($("#old_pass").val());
		                 }},  
		                 dataFilter: function(data, type) {  
		                 	return data;
		                 }  
		              }
		        },
		        new_pass: {     
		            required:true,
		            rangelength:[6, 20]
		        },
		        re_new_pass: {     
		        	rePassword:true
		        }
		    },      
		    /**//* 设置错误信息 */    
		    messages: {     
		    	old_pass: {         
		        	required:"请输入旧密码",
		        	remote:"密码不正确"
		        },
		        new_pass: {         
		        	required:"新密码不可为空",
		        	rangelength:"新密码必须在6-20个字符之间"
		        }
		    },      
		    /**//* 设置验证触发事件 */
		    onsubmit:true,
		    /**//* 设置错误信息提示DOM */    
		    errorPlacement: function(error, element) {   
		    	$(element[0]).parent().next().find("span").text(error.html());  
		    },
		    success:function(error, element){
		    	$(element[0]).parent().next().find("span").text("");  
		    	
	        },
		    submitHandler: function (){
		    	//alert("sunmit");
		    	saveNewPass();
		    }
		});
		
		//修改密码
		$("#repassword").click(function(){
			
			$("#editPassword_dialog input").val("");
			$("#editPassword_dialog span").text("");
			$("#editPassword_dialog input").focus();
			
			layer.open({
			    type: 1,
			    title: "修改密码",
			    area: ['420px', '200px'], //宽高
			    content: $("#editPassword_dialog")
			});
			
		});
		
		//修改密码，保存
		$("#saveBtu").click(function(){
			$("#editPassword_form").submit();
		});
		
		//修改密码，取消
		$("#closeBtu").click(function(){
			layer.closeAll();
		});
	})
	
	//保存新密码
	function saveNewPass(){
		
		var pass = $("#editPassword_dialog #new_pass").val();
		
		$.ajax({
	   		type:"POST",
	   		async: false,  //默认true,异步
	   		dataType:"json",
	   		data:"password="+pass,
	   		url:"<%=request.getContextPath()%>/aDKManageUser/updatePassword.action",
	   		success:function(data){
	   			//alert(JSON.stringify(data));
	   			if(data == "SUCCESS"){
	   				
	   				layer.alert('保存成功！', {icon: 1}, function(index){
	   					layer.closeAll();
	   				});
	   				
	   			}else{
	   				layer.alert('修改失败！', {icon: 0}, function(index){
	   					layer.close(index);
	   				});
	   			}
	   	    }
	   	});
	}
	
	//锁定按钮（确定）
	function lock(){
		if($("#param .text_first").length > 0){
			return false;
		}
		// 准备参数
		var param = new Object();
		param.userName = $.trim($("#name").val());
		param.password = $.trim($("#password").val());
		//alert(param.password);
		//alert(param.userName);
		if(param.password == ""){
			layer.alert('密码不可为空', {icon:0});
			return false;
		}
		$.ajax({
			type:"POST",
			async:true,  //默认true,异步
			data:param,
			dataType:'text',
			url:"${bathPath}/login/tologin.action",
			success:function(data){
				//alert(data);
				if(data=="OK"){
					//window.location.href = "${bathPath}/index/toIndexPage.action";
					
					//隐藏div
					document.getElementById('suo').style.display="none";
				}else if(data == "PASSWORD_ERROR"){
					layer.alert('密码错误', {icon: 2});
				}else if(data == "NO_EXIST"){
					layer.alert('用户不存在！', {icon: 2});
				}else{
					layer.alert('解锁失败！', {icon: 2});
				}
		    }
		});
	}
</script>
		<div class="zhuR">
			<div class="zhuR-nei">
				<iframe id="myIframe" name="mainIframe" frameborder="0" style="height:305px;width:950px;min-width:950px;" src="${bathPath}/emptyPage.jsp"></iframe>
        		<!-- <div id="myIframe" style="width:100%;min-width:950px;border:2px solid red;"></div> -->
        	</div>
        </div>
        
        <div class="beiAn">
        	<span class="beiAn-zi">专业门禁管理软件 SACM-V2.0 | 版权所有2019费浦智能科技有限公司</span>
        </div>
        
        <!--锁定界面-->
       <div id="suo" class="sDing1" style="background-image:url(${bathPath}/image/background.png);">
        	<div class="sDing2">
        	<div>
        		<img src="${bathPath}/image/logo2.png" style="width:247px; height:78px;margin-left:200px;padding-bottom:40px;" id="suoDing"/>
        	</div>
        		<!-- <p class="sDing3">请输入解锁密码</p> -->
        			<input type="text" id="name" name="name" class="sDing4" style="display:block;"/>
        			<br/>
        			<input type="password" placeholder="请输入解锁密码" class="sDing4" id="password" name="password"/>
        			<br/>
        			<input type="button" value="解锁" class="sDing5" onclick="lock()" />
        	</div>
        </div> 
        
        <!--空白页面-->
        <div id="kong" style="background-color:white;width:925px;height:500px;margin-left:235px;margin-top:-545px;z-index:999;position:absolute;display:none;"></div>
</div>
</body>
</html>